load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("scm_server_infra")

rust_library(
    name = "megarepo_mapping",
    srcs = glob([
        "mapping/src/**/*.rs",
        "mapping/schemas/**/*.sql",
    ]),
    autocargo = {"cargo_toml_dir": "mapping"},
    test_deps = [
        "fbsource//third-party/rust:maplit",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mononoke_types:mononoke_types-mocks",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_json",
        "//common/rust/shed/justknobs_stub:justknobs",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/derived_data:fsnodes",
        "//eden/mononoke/derived_data/content_manifest_derivation:content_manifest_derivation",
        "//eden/mononoke/manifest:manifest",
        "//eden/mononoke/megarepo_api/if:megarepo_configs-rust",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/filestore:filestore",
        "//eden/mononoke/repo_attributes/repo_blobstore:repo_blobstore",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/server/context:context",
    ],
)

rust_library(
    name = "megarepo_error",
    srcs = glob(["megarepo_error/src/**/*.rs"]),
    autocargo = {"cargo_toml_dir": "megarepo_error"},
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:thiserror",
        "//eden/mononoke/blobstore:blobstore",
        "//eden/mononoke/derived_data:derived_data_manager",
        "//eden/mononoke/scs/if:source_control-rust",
    ],
)

rust_library(
    name = "megarepo_config",
    srcs = glob([
        "megarepo_config/src/**/*.rs",
        "megarepo_config/schemas/**/*.sql",
    ]),
    autocargo = {"cargo_toml_dir": "megarepo_config"},
    test_deps = [
        "fbsource//third-party/rust:maplit",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:clap",
        "fbsource//third-party/rust:tracing",
        ":megarepo_error",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/sql:sql",
        "//eden/mononoke/blobstore:blobstore_factory",
        "//eden/mononoke/common/futures_watchdog:futures_watchdog",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/megarepo_api/if:megarepo_configs-rust",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/bookmarks:bookmarks",
        "//eden/mononoke/server/context:context",
        "//thrift/lib/rust:fbthrift",
    ],
)

rust_library(
    name = "pushredirect",
    srcs = glob([
        "pushredirect/src/**/*.rs",
        "pushredirect/schemas/**/*.sql",
    ]),
    autocargo = {"cargo_toml_dir": "pushredirect"},
    named_deps = {"bincode": "fbsource//third-party/rust:bincode-2"},
    test_deps = [
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_derive",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/justknobs_stub:justknobs",
        "//common/rust/shed/sql:sql",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/server/context:context",
    ],
)

rust_library(
    name = "megarepo_api",
    srcs = glob(["src/**/*.rs"]),
    test_deps = [
        "fbsource//third-party/rust:maplit",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mononoke_types:mononoke_types-mocks",
        "//eden/mononoke/repo_factory:test_repo_factory",
        "//eden/mononoke/tests/utils:tests_utils",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:bytes",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:itertools",
        "fbsource//third-party/rust:parking_lot",
        "fbsource//third-party/rust:serde_json",
        "fbsource//third-party/rust:tracing",
        ":megarepo_config",
        ":megarepo_error",
        ":megarepo_mapping",
        "//common/rust/shed/async_once_cell:async_once_cell",
        "//common/rust/shed/futures_retry:futures_retry",
        "//common/rust/shed/futures_stats:futures_stats",
        "//common/rust/shed/justknobs_stub:justknobs",
        "//common/rust/shed/sorted_vector_map:sorted_vector_map",
        "//eden/mononoke/blobstore:blobstore",
        "//eden/mononoke/cmdlib/mononoke_app:mononoke_app",
        "//eden/mononoke/derived_data:bulk_derivation",
        "//eden/mononoke/derived_data:fsnodes",
        "//eden/mononoke/derived_data/content_manifest_derivation:content_manifest_derivation",
        "//eden/mononoke/derived_data/mercurial_derivation:mercurial_derivation",
        "//eden/mononoke/features/changesets_creation:changesets_creation",
        "//eden/mononoke/features/commit_transformation:commit_transformation",
        "//eden/mononoke/manifest:manifest",
        "//eden/mononoke/mercurial:mercurial_types",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/mononoke_api:mononoke_api",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/bonsai_hg_mapping:bonsai_hg_mapping",
        "//eden/mononoke/repo_attributes/bookmarks:bookmarks",
        "//eden/mononoke/repo_attributes/commit_graph/commit_graph:commit_graph",
        "//eden/mononoke/repo_attributes/filestore:filestore",
        "//eden/mononoke/repo_attributes/repo_blobstore:repo_blobstore",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/repo_authorization:repo_authorization",
        "//eden/mononoke/repo_factory:repo_factory",
        "//eden/mononoke/server/context:context",
    ],
)
